// Inventory:
var inventory = [
  { count : 2, tile : 'b' },
  { count : 1, tile : 'r' },
  { count : 0, tile : 't' },
  { count : 0, tile : 'T' },
  { count : 1, tile : 'S' },
];
var inventory_selected = 0;

function drawButton(index) {
  var inventory_def = inventory[index];
  var canvas = document.getElementById("button" + index);
  var c2d = canvas.getContext("2d");
  c2d.clearRect(0, 0, text_width * 3, text_height);
  drawNumber(c2d, inventory_def.count, 0, 0, 0);
  drawTile(c2d, text_width, 0, inventory_def.tile);
  if (inventory_selected == index) {
    canvas.className = "button_selected";
  } else {
    canvas.className = "button";
  }
}

function drawButtons() {
  for (var i = 0; i < inventory.length; ++i) {
    drawButton(i);
  }
}

function selectButton(i) {
  var old_selected = inventory_selected;
  inventory_selected = i;
  drawButton(i);
  drawButton(old_selected);
}
